/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"458998D5-884D-41C4-8422-79000140E9E9",variableType:93}
 */
var fFechaDesde = null;

/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"20C0985B-62C4-412B-83FC-D04F9C528FE9",variableType:93}
 */
var fFechaHasta = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"880B6A22-45C3-46D1-8DF8-AB6E6DA48919",variableType:4}
 */
var fplan_id = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"B1AAD5C8-82E2-45C7-9A98-2C5CDF82F502"}
 * @AllowToRunInFind
 */
function buscar(event) 
{
	if ((globals.gFechaDesde != null) && (globals.gFechaHasta != null))
	{
		if (controller.find())
			{
				if (fplan_id != null)
				{
					plan_id = fplan_id
				}
				var Searchdate = utils.dateFormat(globals.gFechaDesde,'dd-MM-yyyy')+'...'+utils.dateFormat(globals.gFechaHasta,'dd-MM-yyyy')
				op_detalle_varios_to_op_cabecera.fecha = '#'+ Searchdate +'|dd-MM-yyyy'
				op_detalle_varios_to_op_cabecera.codigo_movimiento = 6
				var f = controller.search()
				if (f == 0)
					globals.DIALOGS.showWarningDialog('Aviso','No se encontraron resultados','OK')
			}
			else
				globals.DIALOGS.showWarningDialog('Aviso','No se puede buscar','OK')
		}
	else
		globals.DIALOGS.showWarningDialog('Aviso','Por favor ingrese todas las condiciones','OK')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"6BDC9F93-26B0-4397-8998-CFB969234D2B"}
 */
function limpiar(event) 
{
	fplan_id=null;
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"7269E0AF-0F6B-4B4F-8AAF-64EA18E26407"}
 * @AllowToRunInFind
 */
function iniciar(firstShow, event) 
{
	databaseManager.revertEditedRecords()
	databaseManager.setAutoSave(true)
	fplan_id = null;
	controller.find()
	plan_id = 0
	controller.search()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"D9739DD0-978C-41CF-9334-A57D209C5ECD"}
 */
function onAction_detalle(event) {
	forms.opago_varios_dtl.controller.setSelectedIndex(foundset.getSelectedIndex())
	globals.mostrarForm("opago_varios_dtl");
}
